package com.ellricky.teacher

import android.app.Activity
import android.content.Intent
import androidx.fragment.app.Fragment
import com.andr.common.util.StrUtil
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.entity.PersonItemEntity
import com.ellricky.baselib.ui.msg.MsgTipActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.baselib.ui.teacher.EvaluateStudentActivity
import com.ellricky.teacher.ui.mycourse.evaluate.WorkUploadActivity
import com.ellricky.teacher.ui.mycourse.course.CourseStudentActivity
import com.ellricky.baselib.ui.task.beike.PreLessonActivity
import com.ellricky.teacher.ui.mycourse.evaluate.AttendClassStateActivity


internal fun jumpStuClassState(activity: Activity, student: PersonItemEntity?) {
    val intent = Intent(activity, AttendClassStateActivity::class.java)
    intent.putExtra("student", student)
    EAppUtil.jumpForResult(activity, intent)
}

internal fun jumpStuEvaluate(activity: Activity, student: PersonItemEntity?, classStatus: String?) {
    val intent = Intent(activity, EvaluateStudentActivity::class.java)
    intent.putExtra("student", student)
    intent.putExtra("classStatus", classStatus)
    EAppUtil.jumpForResult(activity, intent)
}

internal fun jumpWorkUpload(activity: Activity,
                            customerId: String?, attendId: String?, classStatus: String?,
                            nlFirst: String?, nlSecond: String?,
                            nlThird: String?, nlFour: String?,
                            nlFive: String?) {
    val intent = Intent(activity, WorkUploadActivity::class.java)
    intent.putExtra("customerId", customerId)
    intent.putExtra("attendId", attendId)
    intent.putExtra("classStatus", classStatus)
    intent.putExtra("nlFirst", nlFirst)
    intent.putExtra("nlSecond", nlSecond)
    intent.putExtra("nlThird", nlThird)
    intent.putExtra("nlFour", nlFour)
    intent.putExtra("nlFive", nlFive)
    EAppUtil.jumpForResult(activity, intent)
}

/**
 * attend: 1=备课 0=未备课
 */
internal fun jumpMyCourseItem(activity: Activity?, frg: Fragment?, attend: String?, id: String?, preId: String?) {
    val act = activity ?: frg?.activity
    act?.let {
        val intent: Intent?
        val hasBk = when (StrUtil.filterEmpty(attend, "0")) {
            "1" -> true
            else -> false
        }

        if (hasBk) {
            intent = Intent(act, CourseStudentActivity::class.java)
            intent.putExtra(BaseConstant.KEY_ID, id)
            intent.putExtra("preId", preId)
        } else {
            intent = Intent(act, PreLessonActivity::class.java)
        }

        activity?.let { EAppUtil.jumpForResult(it, intent) }
                ?: EAppUtil.jumpForResult(frg, intent)
    }

}


///////////////////////////////////////////////////////////////////////////
// 我的学生
///////////////////////////////////////////////////////////////////////////

internal fun jumpStuMsgList(fragment: Fragment) {
    val activity = fragment.activity
    activity?.let {
        val intent = Intent(it, MsgTipActivity::class.java)
        EAppUtil.jumpForResult(fragment, intent)
    }
}
